<?
header('Content-Type:application/json;charset=UTF-8');
include("../../com/website_config.php");

$detail_id=(int)$_GET["detail_id"];
//如果detail为null则sql否则sql2
if(empty($detail_id)){
    $sql="select * from ms_product where pro_tid=3 order by pro_id desc";
    $array=array();
    $result=$db->query($sql);
    $i=0;
    if(mysql_num_rows($result)==""){
        echo "暂时还没有信息!";
    }else{
        while($r=mysql_fetch_array($result)){
            $array[$i]=$r;
            $pro_id=str_replace('pro_id','',$r[0].pro_id);
            $photoSql="select * from ms_product_photo where pro_id=$pro_id";
            $photo=$db->query($photoSql);
            if(mysql_num_rows($photo)==""){
                echo "图片缺失!";
            }else{
                $j=0;
                while($p=mysql_fetch_array($photo)){
                    $array[$i]["img"][$j]="../img".substr($p["img_path"],5);
                    $j++;
                }
            }
            $i++;
        }
    }
}else{
    $sql="select * from ms_product where pro_id=$detail_id";
    $array=array();
    $result=$db->query($sql);
    $i=0;
    if(mysql_num_rows($result)==""){
        echo "暂时还没有信息!";
    }else{
        while($r=mysql_fetch_array($result)){
            $array[$i]=$r;
            $i++;
            $pro_id=$detail_id;
            $j=0;
            $photoSql="select * from ms_product_photo where pro_id=$pro_id";
            $photo=$db->query($photoSql);
            while($p=mysql_fetch_array($photo)){
                $array["img"][$j]="../img".substr($p["img_path"],5);
                $j++;
            }
        }

    }
}





echo json_encode($array);

?>